package com.njwb.day15.zqzb.file;

import java.io.File;
import java.io.FilenameFilter;
import java.io.IOException;
import java.util.Arrays;

public class FileDemo04 {
    public static void main(String[] args) throws IOException {
        File parent = new File("E:\\abc");

        //列出文件的时候进行过滤操作
        String[] names = parent.list(new FilenameFilter() {
            @Override
            public boolean accept(File dir, String name) {
                return name.endsWith("txt");

            }
        });




        System.out.println(Arrays.toString(names));

//        for(int i = 0;i<5;i++) {
//            if(i<3) {
//                File f = new File(parent,""+i+".txt");
//                f.createNewFile();
//            }else{
//                File f = new File(parent,""+i+".java");
//                f.createNewFile();
//            }
//        }
    }
}
